var ShowMsgDiv=null;

function DivMsg()
{
	this.AllMsgDiv = null;					//目标Div
    this.CoverDiv	= null;						//遮罩
	this.eventDiv	= null;						//显示div
	this.eventDivMsg	= null;						//显示div

}

DivMsg.prototype.init = function(){
	if(this.AllMsgDiv==null){
		this.AllMsgDiv=document.createElement('DIV');	
		this.AllMsgDiv.style.display='none';
		this.AllMsgDiv.innerHTML='<div id="CoverDivID" style="position:absolute;top:0px;left:0px;z-index:1; background-color:#000000;filter:alpha(opacity=50);-moz-opacity:0.5; opacity: 0.5;text-align:center; visibility:hidden;"></div><div  id="eventMsgDivID"style="position:absolute;width:0px;height:0px;z-index:3; text-align:center; top:0px;left:0px; visibility:hidden"></div> ';
		document.getElementsByTagName('BODY')[0].appendChild(this.AllMsgDiv);	
		//alert(this.CoverDiv)
		this.CoverDiv=document.getElementById('CoverDivID');
		this.eventDiv=document.getElementById('eventMsgDivID');		

	}
	
}


/*************************************************
*
*	显示DIV并传递URL地址
*	type  1  线路
*		  2  自由行
*/
function ShowDiv(lineId,lineName,startPrice,type)
{
	var msg='<div style="width:100%" align="center"><div id="share_border" style="width:500px;background-color:#fff;" align="left"><div class="share_top"><div class="share_top_left">分享线路</div><div class="share_top_right"><a href="javascript:HidDiv()">关闭</a></div></div><div class="share_top_bg"></div><form name="formShare" action="../product/TlineShareAction.php" method="post" onsubmit="return DoSubmitShare(this)"><input type="hidden" name="lineid" value="'+lineId+'" /><div class="share_text">好友称呼 <span>*</span><div style="font-size:11px; color:#999999">(带*为必填写)</div><input type="text" value="" name="contacts" /><br />E-mail <span>*</span><br /><input type="text" value="" name="email" /><br />您的姓名 <span>*</span><br /><input type="text" value="" name="YourName" /><br />发送内容 <span>*</span><br /><textarea rows="6" cols="50" name="emailContent">HI，最近好吗？\n我现在在一家网站上看到了一个比较不错的线路，分享给你。\n工作之余，找个时间给自己休个假吧。\n好心情，才有好的明天的嘛：）\n' ;
	switch(type){
		case 1:
			msg += '/line/'+lineId+'.html \n'+lineName+' ('+startPrice+'元起)';
			break;
		case 2:
			msg += '/vacation/'+lineId+'.html \n'+lineName+' ('+startPrice+'元起)';
			break;
		
	}
	
	msg += '</textarea><br />请输入验证码 <span>*</span><br /><input type="text"  class="input-item4" name="code"/> <a href="javascript:setcode()" class="blue2"><img src="../users/Code.php" id="Checkcode" /> 看不清楚，换一张？</a><div class="share_bt"><a href="#" onclick="if(!DoSubmitShare(\'obj\')) return false;document.formShare.submit();return false;"><img src="../images/share_send.gif" ></a></div></div></form></div></div>';
	ShowDivContent(msg);
	setcode();
}





/*************************************************
*
*	显示DIV并传递URL地址
*
*/
function ShowDivContent(Content)
{
	if(ShowMsgDiv==null) {
		ShowMsgDiv = new DivMsg();
		ShowMsgDiv.init();
	}

	ShowMsgDiv.AllMsgDiv.style.display='';
	ShowMsgDiv.CoverDiv.style.visibility='visible';
	ShowMsgDiv.CoverDiv.style.width = '100%';
		
	ShowMsgDiv.eventDiv.style.visibility='visible';
	ShowMsgDiv.eventDiv.style.width = '100%';
	ShowMsgDiv.eventDiv.innerHTML=Content;
	

	if(document.body.scrollTop){
		ShowMsgDiv.CoverDiv.style.height = document.body.scrollHeight+"px";
		ShowMsgDiv.eventDiv.style.top = document.body.scrollTop+80+"px";
	}
	else{
		ShowMsgDiv.CoverDiv.style.height = document.documentElement.scrollHeight+"px";
		ShowMsgDiv.eventDiv.style.top = document.documentElement.scrollTop+80+"px";
	}
	
	
}

function ShowDivContentMsg(Content,obj)
{
	if(ShowMsgDiv ==null){
		ShowMsgDiv = new DivMsg();
	}
	if(ShowMsgDiv.eventDivMsg==null) {
		var Temp;
		Temp=document.createElement('DIV');	
		document.getElementsByTagName('BODY')[0].appendChild(Temp);
		Temp.innerHTML='<div id="eventDivMsg" style="visibility:hidden;position:absolute;"></div>';
		ShowMsgDiv.eventDivMsg = document.getElementById('eventDivMsg');
	}

	ShowMsgDiv.eventDivMsg.style.visibility='visible';
	ShowMsgDiv.eventDivMsg.innerHTML=Content;
	

	var OBTop=0;
	var OBLeft=0;
	var OBWidth=0;
	var OBHeight=0;

	var oCurrentNode = obj;
	while(oCurrentNode != null && oCurrentNode.tagName != "BODY"){
		OBTop += oCurrentNode.offsetTop;
		OBLeft += oCurrentNode.offsetLeft;
		oCurrentNode = oCurrentNode.offsetParent;
	}

	OBTop += document.getElementsByTagName('BODY')[0].offsetTop 
	OBLeft += document.getElementsByTagName('BODY')[0].offsetLeft 
	
	ShowMsgDiv.eventDivMsg.style.top = (OBTop + 6 + obj.offsetHeight + "px");
	ShowMsgDiv.eventDivMsg.style.left = (OBLeft  + 2 + "px");
	
}

/*************************************************
*
*	关闭DIV
*
*/
function HidDiv()
{
	ShowMsgDiv.AllMsgDiv.style.display='none';
}


function HidDivMsg()
{
	ShowMsgDiv.eventDivMsg.style.visibility='hidden';
}


function ShowStartPrice()
{
	
	var msg='<div style="width:100%" align="center"><div id="share_border" style="background-color:#fff;"><div class="share_top"><div class="share_top_left" align="left">起价说明</div><div class="share_top_right"><a href="javascript:HidDiv()">关闭</a></div></div>	<div class="share_top_bg"></div><div class="price_text" align="left"><img src="../img/order_w.gif" width="18" height="17" />本站线路起价是指在可出行日期内成人最低价格。因同一旅游线路价格受不同航班时间，住宿等级，饮食餐数，淡旺季等外界因素影响而有所不同，详细价格请查看出团日期下的具体报价.<BR>如有疑问，欢迎您致电我们的客服代表：<strong>023-65405535</strong><br /><br /><div class="" style=" background-color:#F8FCFF;">';


	var tempCount = 0 ;
	for(var ii=0; ii<startTime.length && ii<54; ii++ ){
		if(startTime[ii][0]!=""){
			if(tempCount==0){
				msg += '<ul>';
			}
			msg += '<li '+ (startTime[ii][1]==start_price? 'style=" border:1px double #93C6F4; color:#2585D8; background-image:url(../img/price_bt.gif); background-repeat:no-repeat;"':'')  +'>'+startTime[ii][0]+'<Br />RMB'+ startTime[ii][1]  + '</li>';
			
			tempCount += 1
			if(tempCount==6){
				msg += '</ul>';
				tempCount=0;
			}
			
		}
	}

	if(tempCount!=6 && startTime.length>0){
		msg += '</ul>';
	}	

	msg += '</div><div style="height:8px; font-size:0px;clear:both">&nbsp;</div></div></div></div>';
	ShowDivContent(msg);
	
}


function ShowStartPriceMsg(obj,which)
{
	
	var msg='<div class="price_border"><div class="price_borders">'+'<div class="price_border_s"></div><p>';
	if(which!=1){
		msg += '本站线路起价是指在可出行日期内成人最低价格。因同一旅游线路价格受不同航班时间，住宿等级，饮食餐数，淡旺季等外界因素影响而有所不同，详细价格请查看出团日期下的具体报价。如有疑问，欢迎您致电我们的客服代表：<strong>023-65405535</strong>';
	}else{
		msg += '此线路为单独包团线路，根据参加的人数和出团时间，价格可能会有变化，需要一团一议。如有疑问，欢迎您致电我们的客服代表：<strong>023-65405535</strong>';
	}
	msg += '</p></div></div>';
	ShowDivContentMsg(msg,obj)
}



function _ShowStartPriceMsg(obj,which)
{
	
	var msg='<div class="price_border"><div class="price_borders">'+'<div class="price_border_s"></div><p>';
	if(which!=1){
		msg += '本站酒店起价是指在可出行日期内成人最低价格。</strong>';
	}else{
		msg += '此线路为单独包团线路，根据参加的人数和出团时间，价格可能会有变化，需要一团一议。如有疑问，欢迎您致电我们的客服代表：<strong>023-65405535</strong>';
	}
	msg += '</p></div></div>';
	ShowDivContentMsg(msg,obj)
}



function ShowStartAllPrice()
{
	var msg='<div style="margin:auto"><div id="share_border" style="background-color:#fff;"><div class="share_top"><div class="share_top_left" align="left">出发日期</div><div class="share_top_right"><a href="javascript:HidDiv()">关闭</a></div></div>	<div class="price_text" align="left"><div class="" style=" background-color:#F8FCFF;">';


	var tempCount = 0 ;
	for(var ii=0; ii<startTime.length; ii++ ){
		if(startTime[ii][0]!=""){
			if(tempCount==0){
				msg += '<ul>';
			}
			msg += '<li '+ (startTime[ii][1]==start_price? 'style=" border:1px double #93C6F4; color:#2585D8; background-image:url(../images/price_bt.gif); background-repeat:no-repeat;"':'')  +'>'+startTime[ii][0]+'<Br />RMB'+ startTime[ii][1]  + '</li>';
			
			tempCount += 1
			if(tempCount==6){
				msg += '</ul>';
				tempCount=0;
			}
			
		}
	} 	
	
	msg += '</div><div style="height:8px; font-size:0px">&nbsp;</div></div></div></div>';
	ShowDivContent(msg);
	
}




//分享Js
function setcode()
{
	document.getElementById("Checkcode").src="";
	document.getElementById("Checkcode").src="../users/Code.php?id="+new Date();
	
}
function DoSubmitShare(obj)
{
   var a = document.getElementsByTagName("input");
   for (var i=0; i<a.length; i++) 
    {  
   		a[i].value=Trim(a[i].value);
		switch(a[i].name){ 
			case "YourName": 
				if(a[i].value==""){
					alert("请输入您的称呼");
					a[i].select();
					a[i].focus();
					return false;
				}
				break;		
		
			case "contacts": 
				if(a[i].value==""){
					alert("请输入联系人");
					a[i].select();
					a[i].focus();
					return false;
				}
				break;
				
			case "email": 
			    if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(a[i].value))){
					alert("请输入正确的邮件格式");
					a[i].select();
					a[i].focus();
					return false;
				}	
				break;
				
			case "emailContent": 
				if(a[i].value==""){
					alert("请输入Email信息内容");
					a[i].select();
					a[i].focus();
					return false;
				}
				break;		
				
			case "code": 
				if(a[i].value==""){
					alert("请输入验证码");
					a[i].select();
					a[i].focus();
					return false;
				}
				break;		
										
						
			
			default: 
				break;
		}
	}
	
return true;
}
 
